package com.nightsoul.xmlrpc.test.server;

import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.server.XmlRpcStreamServer;
import org.apache.xmlrpc.webserver.WebServer;

import com.nightsoul.xmlrpc.test.handler.Calculator;

public class XmlRpcServer {
	
	public static void main(String[] args) throws Exception {
		WebServer webServer = new WebServer(8800);
		XmlRpcStreamServer rpcStreamServer = webServer.getXmlRpcServer();
		PropertyHandlerMapping handlerMapping = new PropertyHandlerMapping();
		handlerMapping.addHandler("Calculator", Calculator.class);
		rpcStreamServer.setHandlerMapping(handlerMapping);
		
		XmlRpcServerConfigImpl xmlRpcConfig = (XmlRpcServerConfigImpl) rpcStreamServer.getConfig();
		xmlRpcConfig.setEnabledForExtensions(true);
		xmlRpcConfig.setContentLengthOptional(false);
		
		webServer.start();
	}
}
